package org.zfes.snowier.cloud.zbss.cms.router.service.topic;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.cms.topic.model.CmsTopicAttachment;
import org.zfes.snowier.cloud.zbss.cms.topic.service.ICmsTopicAttachmentService;
@Controller 
@RequestMapping("/cms/topic/cmsTopicAttachment")
public class CmsTopicAttachmentController extends BaseController {

	
	@Autowired
	private ICmsTopicAttachmentService cmsTopicAttachmentService;
	
	@RequiresPermissions(value="cmsTopicAttachment:loadCmsTopicAttachmentDataSet",desc="附件列表")
    @RequestMapping(value="/loadCmsTopicAttachmentDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsTopicAttachmentDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  cmsTopicAttachmentService.loadCmsTopicAttachmentDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	@RequiresPermissions(value="cmsTopicAttachment:createCmsTopicAttachment",desc="附件添加")
    @RequestMapping(value="/createCmsTopicAttachment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createCmsTopicAttachment(CmsTopicAttachment cmsTopicAttachment){
		cmsTopicAttachmentService.createCmsTopicAttachment(cmsTopicAttachment);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsTopicAttachment:loadCmsTopicAttachment",desc="附件加载")
    @RequestMapping(value="/loadCmsTopicAttachment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsTopicAttachment(Long id){
		Optional<CmsTopicAttachment> ops = cmsTopicAttachmentService.loadCmsTopicAttachmentById(id);
		return ajaxQuery("cmsTopicAttachment",ops);
    }
	
	@RequiresPermissions(value="cmsTopicAttachment:updateCmsTopicAttachment",desc="附件更新")
    @RequestMapping(value="/updateCmsTopicAttachment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateCmsTopicAttachment(CmsTopicAttachment cmsTopicAttachment){
		cmsTopicAttachmentService.updateCmsTopicAttachment(cmsTopicAttachment);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsTopicAttachment:deletCmsTopicAttachment",desc="附件删除")
    @RequestMapping(value="/deleteCmsTopicAttachment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteCmsTopicAttachment(Long id){
		cmsTopicAttachmentService.deleteCmsTopicAttachment(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}